//
//  SwitchViewController.m
//  CWRD
//
//  Created by lanou on 15/9/17.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "SwitchViewController.h"

@interface SwitchViewController ()

@end

@implementation SwitchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"功能开关";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor cyanColor],NSForegroundColorAttributeName, nil]];
    [self addView];
}

- (void)addView{
    UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, kWidth, 30)];
    name.text = @"- 使用流量时通知我 -";
    name.textAlignment = NSTextAlignmentCenter;
    name.font = [UIFont boldSystemFontOfSize:15];
    [self.view addSubview:name];
    
    NYSegmentedControl *nameSwitch = [[NYSegmentedControl alloc] initWithItems:@[@"打开",@"关闭"]];
    nameSwitch.backgroundColor = [UIColor grayColor];
    nameSwitch.segmentIndicatorBackgroundColor = [UIColor whiteColor];
    nameSwitch.titleTextColor = [UIColor whiteColor];
    nameSwitch.selectedTitleTextColor = [UIColor blackColor];
    [nameSwitch sizeToFit];
    nameSwitch.center = CGPointMake(180, 90);
    [self.view addSubview:nameSwitch];
    
    UILabel *WIFI = [[UILabel alloc] initWithFrame:CGRectMake(0, 130, kWidth, 30)];
    WIFI.text = @"- Wi-Fi下自动缓存每日日报 -";
    WIFI.textAlignment = NSTextAlignmentCenter;
    WIFI.font = [UIFont boldSystemFontOfSize:15];
    [self.view addSubview:WIFI];
    
    NYSegmentedControl *WIFISwitch = [[NYSegmentedControl alloc] initWithItems:@[@"打开",@"关闭"]];
    WIFISwitch.backgroundColor = [UIColor grayColor];
    WIFISwitch.segmentIndicatorBackgroundColor = [UIColor whiteColor];
    WIFISwitch.titleTextColor = [UIColor whiteColor];
    WIFISwitch.selectedTitleTextColor = [UIColor blackColor];
    [WIFISwitch sizeToFit];
    WIFISwitch.center = CGPointMake(180, 190);
    [self.view addSubview:WIFISwitch];
    
    UILabel *cache = [[UILabel alloc] initWithFrame:CGRectMake(0, 230, kWidth, 30)];
    cache.text = @"- 自动缓存已收藏的视频 -";
    cache.font = [UIFont boldSystemFontOfSize:15];
    cache.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:cache];
    
    NYSegmentedControl *cacheSwitch = [[NYSegmentedControl alloc] initWithItems:@[@"打开",@"关闭"]];
    cacheSwitch.backgroundColor = [UIColor grayColor];
    cacheSwitch.segmentIndicatorBackgroundColor = [UIColor whiteColor];
    cacheSwitch.titleTextColor = [UIColor whiteColor];
    cacheSwitch.selectedTitleTextColor = [UIColor blackColor];
    [cacheSwitch sizeToFit];
    cacheSwitch.center = CGPointMake(180, 290);
    [self.view addSubview:cacheSwitch];
    
    
    UIButton *clear = [UIButton buttonWithType:UIButtonTypeCustom];
    clear.frame = CGRectMake(0, 330, kWidth, 30);
    [clear setTitle:@"清除所有缓存" forState:UIControlStateNormal];
    [clear addTarget:self action:@selector(clearCache) forControlEvents:UIControlEventTouchUpInside];
    clear.titleLabel.font = [UIFont boldSystemFontOfSize:15];
    [clear setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    clear.contentHorizontalAlignment =UIControlContentHorizontalAlignmentCenter;
    [self.view addSubview:clear];
    
   
}

- (void)clearCache{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"清除所有视频缓存?" message:@"将删除所有已缓存和进行中的缓存任务" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
